package com.lvyou.service;

import com.lvyou.model.Result;
import com.lvyou.entity.UserModel;
import com.lvyou.mapper.IUserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LoginSrvImpl {
    @Resource
    private IUserMapper dao;
    public Result login(String username, String password){
        System.out.println("LoginSrvImpl"+username+password);
        List<UserModel> list=dao.queryByusername(username);
        Result res=new Result();
        if(list.size()==1){
            UserModel um=list.get(0);
            String passwordDb=um.getPassword();
            if(password.equals(passwordDb)){
                res.setCode(0);
                res.setMsg("登录成功！");
            }else{
                res.setCode(101);
                res.setMsg("账号或者密码错误！");
            }
        }else{
            res.setCode(102);
            res.setMsg("账号或者密码错误！");
        }return res;
    }

}
